$(document).ready(function() {
    // set up the news accordion on the lower page
    $("#deaccordian").accordion({
        header: "h4" ,
        event: "mouseover",
        icons: false,
        autoHeight: false,
        navigation: true
    });
    $("li a:contains(Admin)").addClass('current');
    $("table#boardCompare").hide();
    $("div#users-contain").hide();
    $("select#category").change(get_complaints);
    $("div#ajaxload").hide();
    //  $("p.gear a").mouseover(function(){alert($(this).html());});
    $("#mainContent  input:submit").button();
    $("input:button").button();
   
});
function show_table()
{
    $("#boardCompare tbody tr:even").addClass("even");
    $("#boardCompare tbody tr:odd").addClass("odd");
    $("#boardCompare tbody tr").click(highlight);
    $("div#ajaxload").hide();
    $("table#boardCompare").fadeIn('slow');
}
function get_complaints(){
   
    var category = $("select#category option:selected").text();

    if(category!="- Select One -"){
        $("div#users-contain").hide();
        $("table#boardCompare").hide();
        $("div#ajaxload").show();
        var ob=$("input:hidden#complain_status").get(0);
        var status=ob.name;
        //alert(status);
        data="category="+category+"&status="+status;
        $.ajax({
            type: 'POST',
            url: base_url() + 'de/get_complaints_ajax',
            data: data,
            datatype: "json",
            success : function (result) {
                var data=$.parseJSON(result);
                var html="";
                for(i=0;i<data.length;i++)
                {
                    html+="<tr>";
                    html+= "<td>"+data[i].appid+"</td>";
                    html+= "<td>"+data[i].applydate+"</td>";
                    html+= "<td>"+data[i].title+"</td>";
                    if(status=='Solved')
                    html+= "<td>"+data[i].accomplishdate+"</td>";    
                    html+= "</tr>";
                }
                // alert(html);
                $("table#boardCompare tbody").html(html);
                show_table();
            }
        });
    }

}
function highlight(evt)
{
  $("div#users-contain").hide();
        $("div#ajaxload").show();
  var appid=this.cells[0].innerHTML;
  appid="appid="+appid;

   $.ajax({
            type: 'POST',
            url: base_url() + 'sde/get_action',
            data: appid,
            datatype: "json",
            success : function (result) {
                var data=$.parseJSON(result);
                var html="";
                for(i=0;i<data.length;i++)
                {
                    html+="<tr>";
                    html+= "<td>"+data[i].id+"</td>";
                     html+= "<td>"+data[i].description+"</td>";
                    html+= "<td>"+data[i].startdate+"</td>";
                   
                    html+= "<td>"+data[i].enddate+"</td>";
                    html+= "</tr>";
                }
                // alert(html);
                $("div#users-contain tbody").html(html);
                $("div#ajaxload").hide();
                $("div#users-contain").fadeIn('slow');
                
            }
        });
}

